import BaseBlock from './base'

class Cuboid extends BaseBlock {
    constructor (x, y, z, width) {
        super('cuboid')
        const size = width || this.width
        // BoxGeometry是四边形的原始几何类，它通常使用构造函数所提供的“width”、“height”、“depth”参数来创建立方体或者不规则四边形。
        const geometry = new THREE.BoxGeometry(size, this.height, size)
        // Phong网格材质(MeshPhongMaterial) 一种用于具有镜面高光的光泽表面的材质。
        const meterial = new THREE.MeshPhongMaterial({
            color: 0xffffff,
        })
        // 网格（Mesh）
        this.instance = new THREE.Mesh(geometry, meterial)
        this.instance.receiveShadow = true // 其他元素往上投射阴影
        this.instance.name = 'block'
        this.x = x
        this.y = y
        this.z = z
        this.instance.castShadow = true // 本元素往地上投射阴影
        this.instance.position.x = this.x 
        this.instance.position.y = this.y 
        this.instance.position.z = this.z 
    }
}

export default Cuboid